ποΈGitΠ―ΡΠ°ποΈ
.github/copilot-instructions.md 3648f2d54b3912452e48674e689d07d68ad768e2 (3648f2d5) Text, 7.71 KB
Copilot Instructions for Meshtastic-Android
Repository Summary
Meshtastic-Android is a native Android client application for the Meshtastic mesh networking project. It enables users to communicate via off-grid, decentralized mesh networks using LoRa radios. The app is written in Kotlin and follows modern Android development practices.
Key Repository Details:
β’ Language: Kotlin (primary), with some Java and AIDL files
β’ Build System: Gradle with Kotlin DSL
β’ Size: ~3MB source code across 3 modules
β’ Target Platform: Android API 26+ (Android 8.0+), targeting API 36
β’ Architecture: Modern Android with Jetpack Compose, Hilt DI, Room database
β’ Product Flavors: T383838fdroid (F-Droid) and T383838google (Google Play Store)
β’ Build Types: T383838debug and T383838release
Essential Build & Test Commands
ALWAYS run these commands in the exact order specified to avoid build failures:
Prerequisites Setup
1. JDK Requirement: JDK 21 is required (will fail with other versions)
2. Secrets Configuration: Copy T383838secrets.defaults.properties to T383838local.properties and update:
T282828
Te6edf3MAPS_API_KEYTff7b72=Ta5d6ffyour_google_maps_api_key_here
Te6edf3datadogApplicationIdTff7b72=Ta5d6ffyour_datadog_app_id
Te6edf3datadogClientTokenTff7b72=Ta5d6ffyour_datadog_client_token
3. Clean Environment: Always start with T383838./gradlew clean for fresh builds
Build Commands (Validated Working Order)
T282828
T8b949e# 1. ALWAYS clean first for reliable builds
./gradlew clean
T8b949e# 2. Check code formatting (run before making changes)
./gradlew spotlessCheck
T8b949e# 3. Apply automatic code formatting fixes
./gradlew spotlessApply
T8b949e# 4. Run static code analysis/linting
./gradlew detekt
T8b949e# 5. Build debug APKs for both flavors (takes 3-5 minutes)
./gradlew assembleDebug
T8b949e# 6. Build specific flavor variants
./gradlew assembleFdroidDebug T8b949e# F-Droid debug build
./gradlew assembleGoogleDebug T8b949e# Google debug build
./gradlew assembleFdroidRelease T8b949e# F-Droid release build
./gradlew assembleGoogleRelease T8b949e# Google release build
T8b949e# 7. Run local unit tests (takes 2-3 minutes)
./gradlew Tffa657test
T8b949e# 8. Run specific flavor unit tests
./gradlew testFdroidDebug
./gradlew testGoogleDebug
T8b949e# 9. Run instrumented tests (requires Android device/emulator, takes 5-10 minutes)
./gradlew connectedAndroidTest
T8b949e# 10. Run lint checks for both flavors
./gradlew lintFdroidDebug lintGoogleDebug
Time Requirements
β’ Clean build: 3-5 minutes
β’ Unit tests: 2-3 minutes
β’ Instrumented tests: 5-10 minutes
β’ Detekt analysis: 1-2 minutes
β’ Spotless formatting: 30 seconds
Environment Setup
Required Tools:
β’ Android SDK API 36 (compile target)
β’ JDK 21 (NOT JDK 17 or 11 - build will fail)
β’ Gradle 9.0+ (downloaded automatically by wrapper)
Optional but Recommended:
β’ Install pre-push Git hook: T383838./gradlew spotlessInstallGitPrePushHook --no-configuration-cache
Project Architecture & Layout
Module Structure
T282828
βββ app/ # Main Android application
β βββ src/main/ # Main source code
β βββ src/test/ # Unit tests
β βββ src/androidTest/ # Instrumented tests
β βββ src/fdroid/ # F-Droid specific code
β βββ src/google/ # Google Play specific code
βββ network/ # HTTP API networking library
βββ mesh_service_example/ # AIDL service usage example
βββ buildSrc/ # Build configuration (Configs.kt)
βββ config/ # Linting and formatting configs
βββ detekt/ # Detekt static analysis rules
βββ spotless/ # Code formatting configuration
Key Configuration Files
β’ T383838buildSrc/src/main/kotlin/Configs.kt - Version constants and build config
β’ T383838app/build.gradle.kts - Main app build configuration
β’ T383838config/detekt/detekt.yml - Static analysis rules
β’ T383838config/spotless/.editorconfig - Code formatting rules
β’ T383838gradle.properties - Gradle build settings
β’ T383838secrets.defaults.properties - Template for secrets (copy to T383838local.properties)
Architecture Components
β’ UI Framework: Jetpack Compose with Material 3
β’ State Management: Unidirectional Data Flow with ViewModels
β’ Dependency Injection: Hilt
β’ Navigation: Jetpack Navigation Compose
β’ Local Data: Room database + DataStore preferences
β’ Remote Data: Custom Bluetooth/WiFi protocol + HTTP API (network module)
β’ Background Work: WorkManager
β’ Communication: AIDL service interface (T383838IMeshService.aidl)
Continuous Integration
GitHub Workflows (.github/workflows/)
β’ pull-request.yml - Runs on every PR: build, detekt, tests
β’ reusable-android-build.yml - Shared build logic: spotless, detekt, lint, assemble, test
β’ reusable-android-test.yml - Instrumented tests on Android emulators (API 26, 35)
CI Commands (Must Pass)
T282828
T8b949e# Exact commands run in CI that must pass:
./gradlew :app:spotlessCheck :app:detekt :app:lintFdroidDebug :app:lintGoogleDebug :app:assembleDebug :app:testFdroidDebug :app:testGoogleDebug --configuration-cache --scan
./gradlew :app:connectedFdroidDebugAndroidTest :app:connectedGoogleDebugAndroidTest --configuration-cache --scan
Validation Steps
1. Code Style: Spotless check (auto-fixable with T383838spotlessApply)
2. Static Analysis: Detekt with custom rules in T383838config/detekt/detekt.yml
3. Lint Checks: Android lint for both flavors
4. Unit Tests: JUnit tests in T383838app/src/test/
5. UI Tests: Compose UI tests in T383838app/src/androidTest/
Common Issues & Solutions
Build Failures
β’ Gradle version error: Ensure JDK 21 (NOT 17 or 11)
β’ Missing secrets: Copy T383838secrets.defaults.properties β T383838local.properties
β’ Configuration cache: Add T383838--no-configuration-cache flag if issues persist
β’ Clean state: Always run T383838./gradlew clean before debugging build issues
Testing Issues
β’ Instrumented tests: Require Android device/emulator with API 26+
β’ UI tests: Use T383838ComposeTestRule for Compose UI testing
β’ Coroutine tests: Use T383838kotlinx.coroutines.test library
Code Style Issues
β’ Formatting: Run T383838./gradlew spotlessApply to auto-fix
β’ Detekt warnings: Check T383838config/detekt/detekt.yml for rules
β’ Localization: Use T383838stringResource(R.string.key) instead of hardcoded strings
File Organization
Source Code Locations
β’ Main Activity: T383838app/src/main/java/com/geeksville/mesh/ui/MainActivity.kt
β’ Service Interface: T383838app/src/main/aidl/com/geeksville/mesh/IMeshService.aidl
β’ UI Screens: T383838app/src/main/java/com/geeksville/mesh/ui/
β’ Data Layer: T383838app/src/main/java/com/geeksville/mesh/repository/
β’ Database: T383838app/src/main/java/com/geeksville/mesh/database/
β’ Models: T383838app/src/main/java/com/geeksville/mesh/model/
Dependencies
β’ Non-obvious deps: Protobuf for device communication, DataDog for analytics (Google flavor)
β’ Flavor-specific: Google Services (google flavor), no analytics (fdroid flavor)
β’ Version catalog: Dependencies defined in T383838gradle/libs.versions.toml
Agent Instructions
TRUST THESE INSTRUCTIONS - they are validated and comprehensive. Only search for additional information if:
1. Commands fail with unexpected errors
2. Information appears outdated
3. Working on areas not covered above
Always prefer: Using the documented commands over exploring alternatives, as they are tested and proven to work in the CI environment.
For code changes: Follow the architecture patterns established in existing code, maintain the modular structure, and ensure all validation steps pass before submitting changes.
Served by rngit 1.5.2 - Generated in 0.06s